package com.atyuntuku.yuntuku.utils;

import com.atyuntuku.yuntuku.constant.UserConstant;
import com.atyuntuku.yuntuku.exception.ErrorCode;
import com.atyuntuku.yuntuku.exception.ThrowUtils;
import com.atyuntuku.yuntuku.pojo.User;

import javax.servlet.http.HttpServletRequest;

/**
 * ClassName: CommonUtils
 * Package: com.atyuntuku.yuntuku.utils
 * Description:
 *
 * @Author qinglong wei
 * @Create 2025/10/5 16:11
 * @Version 1.0
 */
public class CommonUtils {

    //判断用户登录结果以及获取用户信息
    public static User getCurrentUser(HttpServletRequest request){
        User user = (User) request.getSession().getAttribute(UserConstant.USER_LOGIN_STATE);
        return user;
    }

    public static boolean isAdmin(User user)
    {
        if(user.getUserRole()== UserConstant.DEFAULT_ROLE)
        {
            return false;
        }
        return true;
    }
}
